\section{Methodology}
\label{sec:method}
For the purpose of this project, we use APARAPI framework to run Hadoop Java applications on heterogeneous GPU architectures. APARAPI translates Java bytecode to OpenCL code, however, it has many limitations  which makes it challenging for translating Hadoop application. To execute Hadoop applications, we refactor the application to an APARAPI compatible code. Our approach is to do an automatic source-to-source refactoring, but at stage we manually translate handful of MapReduce application. Nevertheless, our ultimate goal is to increase the performance without any effort from the user. Our planned is to refactor the original Java code of map function to a modified version. This APARAPI friendly version of Map function will be passed to APARAPI for execution. 

Before calling the use-defined Map function, we call a ``pre-load'' Map function to read as much data as could be fit in GPU memory. We enforce the process by overriding the \emph{run} method in \emph{mapper.java}. Then the refactored APARAPI compatible kernel will be called. Even though APARAPI provides many functionalities, it is very limited in terms of features and supported data types; which arises many challenges for processing common MapReduce codes. Some of these limitations are:
\begin{itemize}
\item only the Java primitive data types boolean, byte, short, int, long, and float.
\item the primitive data type char is not supported.
\item only one-dimensional arrays of primitive data types are supported.
\item  references to or through a Java Object other than the  kernel instance will cause Aparapi to abandon attempting to create OpenCL. 
\item recursive method is not supported.
\end{itemize}•

We will define few refactoring rules in order to over come these issues. As such, for any use of multi-dimensional array, we re-arange the array into multiple one-dimension array, this will solve the issue for some matrix operations like dot product. For the case of methods, all methods of reachable classes should be moved inside the local mapper class. 



